package com.bizfx.component.controls
{	
	import flash.display.DisplayObject;
	
	import com.bizfx.collections.HashMap;
	
	import mx.controls.ProgressBar;
	import mx.core.Application;

	public class PopUpProgressBarManager {
		
		private static var progressBars:HashMap = new HashMap();
		
		public function PopUpProgressBarManager() {
			super();
		}
		
		public static function show(text:String=null, parent:DisplayObject=null, progress:Number=-1, total:Number=100):void {
			var p:DisplayObject;
			if (parent) {
				p = parent;
			} else {
				p = DisplayObject(Application.application);
			}
			var pb:PopUpProgressBar = null;
			if (progressBars.containsKey(p)) {
				pb = (progressBars.get(p) as PopUpProgressBar);
			} else {
				pb = new PopUpProgressBar();
				progressBars.put(p, pb);
			}
			pb.show(text, parent, progress, total);
		}
		
		public static function hide(parent:DisplayObject=null):void {
			var p:DisplayObject;
			if (parent) {
				p = parent;
			} else {
				p = DisplayObject(Application.application);
			}
			if (progressBars.containsKey(p)) {
				(progressBars.get(p) as PopUpProgressBar).hide();
			}
		}
	}
}